package com.databaseprotect;

import java.sql.*;

public class DBHelper {
    private static String diver = "com.mysql.jdbc.Driver";
    //加入utf-8是为了后面往表中输入中文，表中不会出现乱码的情况
    private static String url = "jdbc:mysql://lemonscloud.cn:3306/s3294300?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=FALSE&autoReconnect=true&failOverReadOnly=false";
    private static String user = "";//用户名
    private static String password = "";//密码

    public static Connection getConn() {
        Connection conn = null;
        try {
            Class.forName(diver);
            conn = (Connection) DriverManager.getConnection(url, user, password);//获取连接
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return conn;
    }
}
